<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
	<th:block th:include="include :: header('公司列表')" />
</head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								公司名：<input type="text" name="orgName"/>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="estate:company:add">
					<i class="fa fa-plus"></i> 添加
				</a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var resetPwdFlag = [[${@permission.hasPermi('estate:company:resetPwd')}]];
        var addRoleFlag = [[${@permission.hasPermi('estate:company:add:role')}]];
        var editFlag = [[${@permission.hasPermi('estate:role:edit')}]];
        var prefix = ctx + "estate/company";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                openUrl: prefix + "/user/edit/{id}",
                modalName: "公司",
		        showExport: true,
                columns: [{
					field : 'companyAccount',
					title : '公司登录码',
					sortable: true
				},
                    {
					field : 'orgName',
					title : '公司名',
					sortable: true
				},
				{
                        field : 'compId',
                        title : '公司识别码',
                        sortable: true
                    },
				{
					field : 'estateData',
					title : '过期时间',
					sortable: true
				},
				{
					field : 'estateMoney',
					title : '物业资产上限',
					sortable: true
				},
				{
					field : 'estateIp',
					title : '系统IP',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row) {
		            	var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + resetPwdFlag + '" href="#" onclick="resetPwd(\'' + row.compId + '\')"><i class="fa fa-key"></i>重置密码</a> ')
		            	actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.companyId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + addRoleFlag + '" href="#" onclick="editRole(\'' + row.compId + '\')"><i class="fa fa-edit"></i>系统权限</a> ');
                        return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
        function editRole(id) {
            $.modal.open("配置系统权限", $.operate.openUrl(id));
        }
        function resetPwd(compId) {
            var url = prefix + '/resetPwd/' + compId;
            $.modal.open("重置密码", url, '800', '300');
        }
    </script>
</body>
</html>